package com.lzb.auth.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lzb.auth.domain.MngUser;
import com.lzb.auth.mapper.MngUserMapper;
import com.lzb.common.datasource.ServiceDataSourceAnnotation;
import com.lzb.common.datasource.MultipleDataSource;

@Service(MngUserService.BEAN_PACKAGE_NAME)
public class MngUserService {

	public static final String BEAN_PACKAGE_NAME = "com.lzb.service.MngUserService";
	@Resource
	private MngUserMapper mngUserMapper;
	
    @ServiceDataSourceAnnotation(getServiceDataSource = MultipleDataSource.DATA_SOURCE_MASTER)
	public void add(MngUser user) {
		try {
			mngUserMapper.insert(user);
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	
    @ServiceDataSourceAnnotation(getServiceDataSource = MultipleDataSource.DATA_SOURCE_LOCALHOST)
	public MngUser getMngUserByUUID(String uuid) {
    		return mngUserMapper.selectByUUID(uuid);
	}
	
    @ServiceDataSourceAnnotation(getServiceDataSource = MultipleDataSource.DATA_SOURCE_MASTER)
	public void deleteByUUIDs(String... uuids) {
		mngUserMapper.deleteByUUIDs(uuids);
	}
	
    @ServiceDataSourceAnnotation(getServiceDataSource = MultipleDataSource.DATA_SOURCE_MASTER)
	public void insertBatch(List<MngUser> mngUserLst) {
		try {
			mngUserMapper.insertBatch(mngUserLst);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
